package com.moana.buyTicket.util.email;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

public class EmailUtils 
{
	public static Map<String,String> servers = new HashMap<String,String>();
	
	static
	{
		servers.put("qq.com","http://mail.qq.com");
		servers.put("gmail.com", "http://mail.google.com");
		servers.put("sina.com", "http://mail.sina.com.cn");
		servers.put("163.com", "http://mail.163.com");
		servers.put("126.com", "http://mail.126.com");
		servers.put("yeah.net", "http://www.yeah.net");
		servers.put("sohu.com", "http://mail.sohu.com");
	}
	
	//根据邮件地址得到邮件服务器地址
	public static String getEmailServer(String email)
	{
		if(null == email)
		{
			return null;
		}
		else 
		{
			int pos = email.lastIndexOf('@');
			if(pos<0)
			{
				return null;
			}
			
			String emailSuffix = email.substring(pos+1);
			emailSuffix = emailSuffix.toLowerCase(Locale.US);
			
			if(servers.containsKey(emailSuffix))
			{
				return servers.get(emailSuffix);
			}
			else
			{
				return "http://mail."+emailSuffix;
			}
		}
	}

}
